import pygame
from pygame.locals import *
from mastergoal.common.piece import *
from util.vector import *
import os

GRAPHICS_PATH = 'mastergoal/gui/graphics'
PIECES_PATH = 'mastergoal/gui/graphics/pieces'

PIECE_SIZE = (40,40)

class GameEntity():
    def __init__(self, file, position=None, path=None):
        path = path or GRAPHICS_PATH
        self.image = pygame.image.load(os.path.join(path, file)).convert_alpha()
        self.position = position
        # Move properties
        self.moving = False
        self.heading = None
        
    def get_coords(self):
        
        return (self.position.left, self.position.top)

class BoardEntity(GameEntity):
    def __init__(self, board, file, position=None):
        GameEntity.__init__(self, file, position, GRAPHICS_PATH)
        self.board = board
        
class BallEntity(GameEntity):
    def __init__(self, ball, file, position=None):
        self.piece = ball
        GameEntity.__init__(self, file, position, PIECES_PATH)
        
class PieceEntity(GameEntity):
    def __init__(self, piece, file, position=None):
        name = '/' + piece.team.name
        self.piece = piece
        GameEntity.__init__(self, file, position, PIECES_PATH + name)